<!-- 全部商品展示模块 -->
<template>
  <div>
    <!-- 面包屑 -->
    <el-row>
      <el-col :span="20" :offset="2">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item
            ><el-link @click="handleIndex">首页</el-link></el-breadcrumb-item
          >
          <el-breadcrumb-item>全部商品</el-breadcrumb-item>
          <el-breadcrumb-item>分类</el-breadcrumb-item>
        </el-breadcrumb>
      </el-col>
    </el-row>
    <!-- 主题 -->
    <el-row>
      <el-col :span="20" :offset="2" style="margin-top: 20px">
        <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
          <el-tab-pane
            type="card"
            :label="item.cat_name"
            :name="item.cat_id + ''"
            v-for="(item, index) in categoriesList"
            :key="index"
          >
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="20" :offset="2">
        <IndexList></IndexList>
      </el-col>
    </el-row>
    <!-- 数据显示栏 -->
    <!-- <el-row>
      <el-col :span="20" :offset="2">
        <el-row class="row_ml" :gutter="20">
          <el-col
            :span="4"
            v-for="(item, index) in list"
            :key="index"
            class="elcolcla"
            ><router-link
              :to="{
                path: '/details',
                query: { productID: item.goods_id },
              }"
            >
              <div class="grid-content">
                <div class="g_img">
                  <img
                    :src="$target + '/sharePath/' + item.pics[0].pic"
                    alt=""
                  />
                </div>
                <span class="g_title">{{ item.goods_name }}</span
                ><br />
                <span class="g_gold">￥{{ item.goods_price }}</span>
              </div>
            </router-link></el-col
          >
        </el-row>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="20" :offset="2" class="uil">
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage1"
          layout="total, prev, pager, next, jumper"
          :total="total"
          :page-size="24"
          background
        >
        </el-pagination>
      </el-col>
    </el-row> -->
  </div>
</template>
<script>
import IndexList from "@/components/IndexList.vue";

export default {
  name: "MyList",
  data() {
    return {
      currentPage1: 1, //初始默认页码
      currentList: "", //当前商品列表
      list: [],
      total: 1,
      categoriesList: [],
      activeName: "0",
    };
  },
  components: {
    IndexList,
  },
  methods: {
    async handleShowCate() {
      const { data: res } = await this.$axios.get(
        "/categories?pagesize=20&pagenum=1",
        {}
      );
      res.data.result.forEach((element) => {
        let list = [];
        list.cat_id = element.cat_id;
        list.cat_name = element.cat_name;
        element = list;
      });

      let list = [];
      list.cat_id = 0;
      list.cat_name = "全部";
      res.data.result.unshift(list);

      if (
        this.$route.query.catId !== undefined &&
        this.$route.query.catId !== null
      ) {
        this.activeName = "" + this.$route.query.catId;
      } else {
        this.activeName = "" + res.data.result[0].cat_id;
      }
      this.categoriesList = res.data.result;
    },
    handleClick(tab) {
      this.$router.push({ path: "/myList", query: { catId: tab.name } });
      this.$router.go(0);
    },
    handleIndex() {
      this.$router.push("/indexContent");
    },
    handleChangeCatId() {},
  },
  created() {
    this.handleShowCate();
    this.handleChangeCatId();
  },
};
</script>
<style scoped>
a {
  text-decoration: none;
  color: #000;
}
.row_ml {
  background: rgb(238, 238, 238);
}
.grid-content {
  border-radius: 4px;
  display: flex;
  max-height: 322px;
  flex-direction: column;
  align-items: center;
  background: white;
  box-sizing: border-box;
  margin-top: 20px;
  text-align: center;
}
.g_img {
  box-sizing: border-box;
}
.g_img img {
  width: 80%;
  height: 140px;
  margin: 20px 0px;
}
.g_title {
  font-size: 15px;
  width: 80%;
  height: 40px;
  line-height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.g_gold {
  height: 20px;
  line-height: 20px;
  margin-bottom: 5px;
}
.elcolcla {
  border-radius: 4px;
  -webkit-transition: all 0.2s linear;
  transition: all 0.2s linear;
  z-index: 1;
}
.elcolcla:hover {
  z-index: 2;
  -webkit-box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  -webkit-transform: translate3d(0, -2px, 0);
  transform: translate3d(0, -2px, 0);
}
.uil {
  height: 60px;
  margin-top: 20px;
  text-align: left;
}
</style>
